package models.domain;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "Contract")
public class Contract {

	@Id
	@Column(name = "id")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;

	@Column(name = "contractStartDate")
	private Date contractStartDate;

	@Column(name = "contractEndDate")
	private Date contractEndDate;

	@Column(name = "telephoneNumber")
	private String telephoneNumber;

	@Column(name = "subscriptionFee")
	private Float subscriptionFee;

	@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
	@JoinColumn(name = "contractItemId")
	private List<ContractItem> contractItems = new ArrayList<ContractItem>();

	@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
	@JoinColumn(name = "billId", nullable = true)
	private List<Bill> bills = new ArrayList<Bill>();

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getContractStartDate() {
		return contractStartDate;
	}

	public void setContractStartDate(Date contractStartDate) {
		this.contractStartDate = contractStartDate;
	}

	public Date getContractEndDate() {
		return contractEndDate;
	}

	public void setContractEndDate(Date contractEndDate) {
		this.contractEndDate = contractEndDate;
	}

	public String getTelephoneNumber() {
		return telephoneNumber;
	}

	public void setTelephoneNumber(String telephoneNumber) {
		this.telephoneNumber = telephoneNumber;
	}

	public Float getSubscriptionFee() {
		return subscriptionFee;
	}

	public void setSubscriptionFee(Float subscriptionFee) {
		this.subscriptionFee = subscriptionFee;
	}

	public List<ContractItem> getContractItem() {
		return contractItems;
	}

	public void setContractItem(List<ContractItem> contractItem) {
		this.contractItems = contractItem;
	}

	public List<Bill> getBill() {
		return bills;
	}

	public void setBill(List<Bill> bill) {
		this.bills = bill;
	}

	public void addBill(Bill bill) {
		bills.add(bill);
	}

	public void addConstraItem(ContractItem item) {
		contractItems.add(item);
	}

}
